#!/usr/bin/ruby
ENV['RAILS_ENV'] ||= 'production'
Dir.chdir(File.expand_path(File.dirname(__FILE__) + "/..")) #Change current directory to RAILS_ROOT
require "config/environment"
include ActionController::UrlWriter
default_url_options[:host] = 'www.amtransservices.com'

filename = "#{RAILS_ROOT}/public/sitemap.xml"

File.open(filename, "w") do |file|
  xml = Builder::XmlMarkup.new(:target => file, :indent => 2)
  
  xml.instruct!
  xml.urlset "xmlns" => "http://www.sitemaps.org/schemas/sitemap/0.9" do
    xml.url do
      xml.loc url_for(:controller => :page, :action => :home)
      xml.changefreq "monthly"
      xml.priority 0.5
    end
    xml.url do
      xml.loc url_for(:controller => :page, :action => :fleet)
      xml.changefreq "monthly"
      xml.priority 0.5
    end
    xml.url do
      xml.loc url_for(:controller => :page, :action => :rates)
      xml.changefreq "monthly"
      xml.priority 0.5
    end
    xml.url do
      xml.loc url_for(:controller => :page, :action => :about)
      xml.changefreq "monthly"
      xml.priority 0.5
    end
    xml.url do
      xml.loc url_for(:controller => :page, :action => :reserve)
      xml.changefreq "monthly"
      xml.priority 0.5
    end
    xml.url do
      xml.loc url_for(:controller => :page, :action => :feedback)
      xml.changefreq "monthly"
      xml.priority 0.5
    end
  end
end